package cn.m3a1.service.admin;

import cn.m3a1.bean.SysLog;
import cn.m3a1.bean.SysLogExample;
import cn.m3a1.dao.SysLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wyj
 * @date 2019/7/8
 * @time 上午9:05
 */
@Service
public class AdminSysService {
    @Autowired
    SysLogMapper sysLogMapper;

    /**
     * 获取所有的日志信息
     *
     * @return
     */
    public List<SysLog> getAllSys() {
        SysLogExample sysLogExample = new SysLogExample();
        List<SysLog> sysLogs = sysLogMapper.selectByExample(sysLogExample);
        return sysLogs;
    }
    /**
     * 获取所有的日志信息
     *
     * @return
     */
    public List<SysLog> getAllSys(String sys) {
        SysLogExample sysLogExample = new SysLogExample();
        SysLogExample.Criteria criteria = sysLogExample.createCriteria();
        criteria.andWhoLike("%"+sys+"%");
        List<SysLog> sysLogs = sysLogMapper.selectByExample(sysLogExample);
        return sysLogs;
    }
    public Boolean delSys(int id) {
        SysLogExample sysLogExample=new SysLogExample();
        SysLogExample.Criteria criteria = sysLogExample.createCriteria();
        criteria.andIdEqualTo(id);
        int i = sysLogMapper.deleteByExample(sysLogExample);
        return i==1;
    }


}